import { IsNumber, IsString, Length } from 'class-validator';
import { PartialType } from '@nestjs/mapped-types';
import { Paging } from '../../common/common.dto';

export class CandidateDto {
  @IsString()
  @Length(2, 10, {
    message: JSON.stringify({
      message: '候选人名称长度必须在2到10个字符之间',
      code: 4000,
    }),
  })
  readonly name: string;

  @IsNumber(
    {
      allowNaN: false,
      allowInfinity: false,
    },
    {
      message: JSON.stringify({ message: '性别值错误', code: 4001 }),
    },
  )
  readonly gender: number;
}

export class CandidateUpdDto extends PartialType(CandidateDto) {
  @IsNumber(
    {
      allowNaN: false,
      allowInfinity: false,
    },
    {
      message: JSON.stringify({ message: '状态值错误', code: 4002 }),
    },
  )
  readonly status?: number;
}

export class QueryCandidateDto extends PartialType(Paging) {
  readonly name?: string;
  readonly gender?: number;
  readonly status?: number;
}
